import _Vue, { PluginObject } from "vue";

import Http from './http';


declare module "vue/types/vue" {
    interface Vue {
        $http: Http;
    }
}

/** 暴露 Http插件 */
export const http: Http = new Http();

/** 暴露 Http插件初始化 */
export const HttpPlugin: PluginObject<string> = {
    install: function (Vue: typeof _Vue, baseUrl?: string, debug?: boolean) {
        Vue.prototype.$http = http;
        Vue.prototype.$http.debug = debug || false;
        Vue.prototype.$http.baseUrl = baseUrl || '';
    }
};

/** 默认 暴露Http插件初始化 */
export default HttpPlugin;
